package com.netease.financial.common.util;

import android.util.Log;

import com.netease.financial.common.config.NfsConfig;

/**
 * Created by wyf on 6/6/15.
 */
public class NfsLog {
    // TODO:  Change to false before the product is publish
    public static final boolean DEBUG_MODE = NfsConfig.isTestEnabled();

    private static final String TAG_PREFIX = "NFS";

    private static final boolean INFO_OPEN = NfsConfig.isInfoLogEnabled();
    private static final boolean VERBOSE_OPEN = NfsConfig.isVerboseEnabled();
    private static final boolean DEBUG_OPEN = NfsConfig.isDebugLogEnabled();
    private static final boolean WARNING_OPEN = NfsConfig.isWarningLogEnabled();
    private static final boolean ERROR_OPEN = NfsConfig.isErrorLogEnabled();
    private static final boolean STACK_OPEN = NfsConfig.isStackLogEnabled();

    public static void e(String tag, String msg) {
        if (ERROR_OPEN) {
            Log.e(TAG_PREFIX + tag, msg);
        }
    }

    public static void e(String tag, String msg, Throwable tr) {
        if (ERROR_OPEN) {
            Log.e(tag, msg, tr);
        }
    }

    public static void d(String tag, String msg) {
        if (DEBUG_OPEN) {
            Log.d(TAG_PREFIX + tag, msg);
        }
    }

    public static void v(String tag, String msg) {
        if (VERBOSE_OPEN) {
            Log.v(TAG_PREFIX + tag, msg);
        }
    }

    public static void i(String tag, String msg) {
        if (INFO_OPEN) {
            Log.i(TAG_PREFIX + tag, msg);
        }
    }

    public static void w(String tag, String msg) {
        if (WARNING_OPEN) {
            Log.w(TAG_PREFIX + tag, msg);
        }
    }

    public static void printStackTraceString(String msg) {
        if (STACK_OPEN) {
            Log.d(TAG_PREFIX, msg + "\n" + Log.getStackTraceString(new Throwable()));
        }
    }
}
